package cn.dapeng.random;

/**
 * @BelongProject study
 * @BelongPackage cn.dapeng.random
 * @Description TODO
 * @ClassName RandomT03
 * @Author xupenghong
 * @Date 2024/8/27 16:38
 * @Version 1.0.0
 */
public class RandomT03 {


    /**
     * 创建一个最小值为minValue，最大值为maxValue等概率随机数
     * @param minValue
     * @param maxValue
     * @return
     */
    public static int g0(int minValue, int maxValue) {
        return (1 + (int) (Math.random() * minValue)) + (maxValue - minValue);
    }

    public static void main(String[] args) {
        int testTime = 10_0000;

        int[] count = new int[20];
        for (int i = 0; i < testTime; i++) {
            count[g0(20, 50) - 31] ++;
        }

        for (int i = 0; i < count.length; i++) {
            System.out.println(i + " : " + count[i]);
        }
    }
}
